package com.hnu.highlynewapp.app;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hnu.highlynewapp.entity.DepartmentInfoEntity;
import com.hnu.highlynewapp.service.DepartmentInfoService;
import com.hnu.highlynewapp.utils.PageUtils;
import com.hnu.highlynewapp.utils.R;
import springfox.documentation.annotations.ApiIgnore;


/**
 * 科技主管部门信息
 *
 * @author hnu_worker
 * @email 825963704@qq.com
 * @date 2021-01-03 10:35:56
 */
@RestController
@RequestMapping("/departmentinfo")
public class DepartmentInfoController {
    @Autowired
    private DepartmentInfoService departmentInfoService;

    /**
     * 列表
     */
    @ApiIgnore
    @RequestMapping("/list")
    //@RequiresPermissions("highlynewapp:departmentinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = departmentInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiIgnore
    @RequestMapping("/info/{departmentId}")
    //@RequiresPermissions("highlynewapp:departmentinfo:info")
    public R info(@PathVariable("departmentId") Long departmentId){
		DepartmentInfoEntity departmentInfo = departmentInfoService.getById(departmentId);

        return R.ok().put("departmentInfo", departmentInfo);
    }

    /**
     * 保存
     */
    @ApiIgnore
    @RequestMapping("/save")
    //@RequiresPermissions("highlynewapp:departmentinfo:save")
    public R save(@RequestBody DepartmentInfoEntity departmentInfo){
		departmentInfoService.save(departmentInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiIgnore
    @RequestMapping("/update")
    //@RequiresPermissions("highlynewapp:departmentinfo:update")
    public R update(@RequestBody DepartmentInfoEntity departmentInfo){
		departmentInfoService.updateById(departmentInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiIgnore
    @RequestMapping("/delete")
    //@RequiresPermissions("highlynewapp:departmentinfo:delete")
    public R delete(@RequestBody Long[] departmentIds){
		departmentInfoService.removeByIds(Arrays.asList(departmentIds));

        return R.ok();
    }

}
